﻿
        function is_rating_locked ()
        {
            var cont = document.getElementById ("rating_locked_container");
            var list = cont.getElementsByTagName ("input");
            
            if (list [0] != null)
                return list [0].value == "true";
            return false;
        }
        
        function get_rating_average ()
        {
            var cont = document.getElementById ("rating_avg_container");
            var list = cont.getElementsByTagName ("input");
            
            if (list [0] != null)
                return list [0].value;
            return 0;
        }
        
        function ratings_clear ()
        {
            if (is_rating_locked ())
                return;
                
            var i;
            var rating_average = get_rating_average ();
            var stars = document.getElementsByClassName("RatingsStar")
           
            for (i = 0; i < rating_average; i++)
                stars [i].src = "media/rating-star-full.gif";
            
            for ( ; i < 5; i++)
                stars [i].src = "media/rating-star-empty.gif";
        }

        function ratings_set (rating)
        {
            if (is_rating_locked ())
                return;
                
            var i;
            var stars = document.getElementsByClassName("RatingsStar")
           
            for (i = 0; i < rating; i++)
                stars [i].src = "media/rating-star-full.gif";
            
            for ( ; i < 5; i++)
                stars [i].src = "media/rating-star-empty.gif";
                
            rating_average = rating;
        }
